package com.qunduikj.sjb.sdk.model.enums;

/**
 * Created by litao on 2015/12/1.
 */
public enum LoanType  {


    // 利用构造函数传参  "未收回", "已收回"
    RoadToll(0, "未收回"), AddCheer(1, "已收回");

    // 定义私有变量
    private int code;
    private String description;
    // 构造函数，枚举类型只能为私有

    LoanType(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public LoanType setCode(int code) {
        this.code = code;
        return this;
    }

    public String getDescription() {
        return description;
    }

    public LoanType setDescription(String description) {
        this.description = description;
        return this;
    }

    @Override
    public String toString() {
        return "LoanType{" +
                "code=" + code +
                ", type='" + description + '\'' +
                '}';
    }

    public static LoanType getByCode(int type) {
        LoanType cartype[] = LoanType.values();
        for (int i = 0; i < cartype.length; i++) {
            LoanType pw = cartype[i];
            if (pw.getCode() == type) {
                return pw;
            }
        }
        return LoanType.RoadToll;
    }

}
